import torch
import torch.onnx
import onnx
import onnxruntime

onnx_model = onnx.load("NeuralNetwork.onnx")

try:
    onnx.checker.check_model(onnx_model)
except onnx.checker.ValidationError as e:
    print("the model is invalid:%s"%e)
else:
    print("the model is valid")

onnx_file_name="NeuralNetwork.onnx"
dummy_input=torch.randn(1,1,28,28,requires_grad=True)
input_img = dummy_input.numpy()
ort_session=onnxruntime.InferenceSession(onnx_file_name,providers=["CUDAExecutionProvider","CPUExecutionProvider"])
ort_inputs={ort_session.get_inputs()[0].name:input_img}
ort_putput=ort_session.run(None,ort_inputs)[0]
